package com.nstar.base.controls
{
	import mx.containers.HBox;
	import mx.controls.ProgressBar;
	import mx.core.Application;
	import mx.managers.PopUpManager;
	
    public class ImageLoader extends HBox   
    {   
 		private static var il:ImageLoader;
 		private var pb:ProgressBar;
		
        public function ImageLoader()   
        {   
        	
        	pb = new ProgressBar();
        	this.addChild(pb);
        	//设置进度条的样式
        	this.setStyle("borderStyle","solid");
        	this.setStyle("backgroundColor",0xFFFFFF);
        	this.setStyle("backgroundAlpha",0.618);
        	this.setStyle("dropShadowEnabled",true);
        	this.setStyle("cornerRadius",2);
        	this.setStyle("horizontalAlign","center");
        	this.setStyle("verticalAlign","middle");
        	this.width = 150;
        	this.height = 30;
        }
		
		//显示进度条
		public static function show(parentWin:* = null,modal:Boolean = false):void{
			if (il == null){
				il = new ImageLoader();
				il.pb.width = 100;
				il.pb.height = 10;
				il.pb.indeterminate = true;
				il.pb.label ="";
				il.pb.labelPlacement = "center";
				if (parentWin == null){
					parentWin = Application.application;
				}
				PopUpManager.addPopUp(il,parentWin,modal);
				PopUpManager.centerPopUp(il);
			}
		}        
		
		//隐藏进度条
		public static function hide():void{
			if (il!=null){
				PopUpManager.removePopUp(il);
				il = null;	
			}
			
		}
		
    }
}